/**
 * 
 */
package ua.kiev.ntukpi.asu.ga.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import ua.kiev.ntukpi.asu.ga.Individual;
import ua.kiev.ntukpi.asu.ga.interfaces.Fitness;
import ua.kiev.ntukpi.asu.ga.interfaces.Remover;

/**
 * @author Alexander Galibey
 *
 */
public class RemoverWorst implements Remover {

	private static final String NAME = "The Worst Remover";
	private Fitness fitness;
	
	public RemoverWorst(Fitness fitness) {
		
		this.fitness = fitness;
	}
	
	public void remove(List<Individual> population, List<Individual> parents,
			List<Individual> childs) {
		
		List<Individual> sortedList = new ArrayList<Individual>(population);
		Collections.sort(sortedList, fitness.getComparator());
		population.removeAll(sortedList.subList(0, 2));
	}

	
	public String getName() {
		
		return NAME;
	}

}
